import "../css/index-CCrXbCN0.css";
import { defineComponent as B, toRefs as M, computed as P, ref as c, nextTick as G, onMounted as L, openBlock as C, createElementBlock as Q, createElementVNode as t, createVNode as d, unref as l, withCtx as p, createTextVNode as m, toDisplayString as k, createBlock as W, createCommentVNode as z, pushScopeId as A, popScopeId as F } from "vue";
import { t as H, an as w, bM as J, d as K, bN as O, f as i } from "./vendor.CF2kwqqq.js";
import { C as X } from "./main.DDNsfpKl.js";
import { _ as Y } from "./_plugin-vue_export-helper.CHgC5LLL.js";
const S = (n) => (A("data-v-a4adb4f6"), n = n(), F(), n), Z = { class: "nifi-data-warehouse" }, $ = { class: "uno-uu2tbn" }, ee = /* @__PURE__ */ S(() => /* @__PURE__ */ t("span", null, "数据输入", -1)), oe = { class: "uno-uu2tbn" }, ae = { class: "uno-nj38jj" }, le = /* @__PURE__ */ S(() => /* @__PURE__ */ t("span", null, "SQL语句", -1)), te = { class: "uno-lkdv8u" }, se = /* @__PURE__ */ B({
  __name: "index",
  props: {
    formdata: {},
    inputV: {},
    inputV2: {},
    inputV3: {},
    step: {},
    api: {}
  },
  setup(n) {
    const y = n, { formdata: s, step: E, api: I, inputV: h, inputV2: x, inputV3: b } = M(y);
    let _ = P(() => E.value === "running");
    const u = c(h.value ? h.value : "dw"), T = (o) => {
      f.value = "", i(s.value, "config.properties['Table Name']", ""), i(s.value, "config.properties['warehouse-type']", o), g();
    }, f = c(x.value), V = c([]), R = {
      children: "children",
      label: "label",
      disabled: "disabled"
    }, q = (o) => {
      o.isDir || i(s.value, "config.properties['Table Name']", o.label);
    }, D = c(), U = c("");
    b.value && G(() => {
      var o;
      (o = D.value) == null || o.insertValue(b.value);
    });
    const j = (o) => {
      i(s.value, "config.properties['db-fetch-sql-query']", o);
    }, g = async () => {
      var a;
      const o = "/hanyun/datadevelop-stream/openMetadata/warehouseTree?pathName=" + u.value;
      try {
        const e = await ((a = I.value) == null ? void 0 : a.get(o));
        V.value = N(e.result), i(
          s.value,
          "config.properties['Database Connection Pooling Service']",
          e[u.value + "ControllerServiceId"]
        ), i(
          s.value,
          "config.properties['qdbtr-record-writer']",
          e.recordControllerServiceId
        );
      } catch (e) {
        console.log(e);
      }
    };
    L(() => {
      g();
    });
    function N(o) {
      let a = [];
      for (const e of o) {
        const v = {
          id: e.id,
          label: e.treeName,
          isDir: e.isDir,
          children: [],
          disabled: !!e.isDir
        };
        if (e.subDirs)
          for (const r of e.subDirs)
            v.children.push(N([r])[0]);
        if (e.leafNodes)
          for (const r of e.leafNodes)
            v.children.push({
              id: r.id,
              label: r.treeName,
              isDir: r.isDir,
              children: [],
              disabled: !!r.isDir
            });
        a.push(v);
      }
      return a;
    }
    return (o, a) => (C(), Q("div", Z, [
      t("div", $, [
        ee,
        d(l(H), {
          modelValue: u.value,
          "onUpdate:modelValue": a[0] || (a[0] = (e) => u.value = e),
          onChange: T,
          disabled: l(_)
        }, {
          default: p(() => [
            d(l(w), { value: "dw" }, {
              default: p(() => [
                m("数据仓库")
              ]),
              _: 1
            }),
            d(l(w), { value: "dim" }, {
              default: p(() => [
                m("统一维度库")
              ]),
              _: 1
            })
          ]),
          _: 1
        }, 8, ["modelValue", "disabled"])
      ]),
      t("div", oe, [
        t("span", null, k(u.value === "dw" ? "数仓表" : "维度表"), 1),
        d(l(J), {
          placeholder: "",
          modelValue: f.value,
          "onUpdate:modelValue": a[1] || (a[1] = (e) => f.value = e),
          data: V.value,
          props: R,
          "highlight-current": "",
          "node-key": "id",
          "default-expand-all": "",
          filterable: "",
          disabled: l(_),
          onNodeClick: q
        }, {
          default: p(({ data: e }) => [
            d(l(K), null, {
              default: p(() => [
                e != null && e.isDir ? (C(), W(l(O), { key: 0 })) : z("", !0)
              ]),
              _: 2
            }, 1024),
            m(" " + k(e.label), 1)
          ]),
          _: 1
        }, 8, ["modelValue", "data", "disabled"])
      ]),
      t("div", ae, [
        le,
        t("div", te, [
          d(X, {
            ref_key: "codeEditorRef",
            ref: D,
            "model-value": U.value,
            "onUpdate:modelValue": j
          }, null, 8, ["model-value"])
        ])
      ])
    ]));
  }
}), ce = /* @__PURE__ */ Y(se, [["__scopeId", "data-v-a4adb4f6"]]);
export {
  ce as D
};
